package org.istt.domain;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.apache.commons.lang.builder.HashCodeBuilder;

/**
 * Field entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "TBL_FIELD", schema = "dbo", catalog = "onegate")
public class Field extends BaseObject<Long> implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 4659125640771564096L;
	private Long id;
	private String name;
	private String description;
	private Set<Category> categories = new HashSet<Category>(0);

	//NDTHO.2011.11.07
	private Department department;
	// Constructors

	/** default constructor */
	public Field() {
	}

	/** full constructor */
	public Field(String name, String description, Set<Category> categories, Department department) {
		this.name = name;
		this.description = description;
		this.categories = categories;
		this.department = department;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "ID", unique = true, nullable = false)
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "NAME" , length = 200)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "DESCRIPTION", length = 1000)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "field")
	public Set<Category> getCategories() {
		return this.categories;
	}
	
	public void setDepartment(Department department) {
		this.department = department;
	}

	@ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="DEP_ID")
	public Department getDepartment() {
		return department;
	}

	public void setCategories(Set<Category> categories) {
		this.categories = categories;
	}
	
	@Override
	public int hashCode() {
		return HashCodeBuilder.reflectionHashCode(this, new String[]{"categories"});
	}

	@Override
	public String toString() {
		
		return null;
	}

	@Override
	public boolean equals(Object o) {
		
		return false;
	}

}